package com.zbb.user.api;

import com.zbb.base.model.Result;
import com.zbb.user.model.dto.UserRegisterFrom;
import com.zbb.user.model.po.User;
import com.zbb.user.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

@Api(value = "用户注册接口",tags = "用户注册接口")
@RestController
public class RegisterController {

    @Autowired
    UserService userService;

    @PostMapping("/register")
    public Result register(@RequestBody UserRegisterFrom userRegisterFrom){
        //检验数据库中是否存在
        Result register = userService.register(userRegisterFrom);
        if (register.getStatus() == 200) {
            return Result.ok("注册成功");
        }
        else {
            return Result.fail(register.getErrorMsg());
        }
    }

}
